<%@ page language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp" %>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame" %>
<head>
    <title>公共平台 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 样式文件的引入 -->
    <link href="${ctx}/commons/css/style.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/commons/themes/icon.css">
    <!-- jqueryUI JS文件的引入 -->
    <script type="text/javascript" src="${ctx}/commons/js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="${ctx}/commons/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${ctx}/commons/js/easyui-extends-validate.js"></script>
    <!-- jqueryUI国际化 -->
    <script type="text/javascript" src="${ctx}/commons/js/easyui-lang-zh_CN.js"></script>
    <!-- 开发使用的公用js方法 -->
    <script type="text/javascript" src="${ctx}/commons/js/common.js"></script>
    <!-- 开发国际化的引用，主要完成后台信息在前台提示的国际化，一定要放在最后 -->
    <script type="text/javascript">var ctx = '${ctx}';
    var actionExt = "action";
    var i18n = new Object();</script>
    <script src="${ctx}/commons/js/i18n/message_zh_CN.js" type="text/javascript"></script>
</head>

<body>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="padding: 4px;height: 80px;overflow: hidden;">
        <div class="easyui-panel" data-options="fit:true,border:true">
            <div class="queryContent">
                <form name="searchProjectsForm" id="searchProjectsForm" method="post" action="" style="display: none; ">
                    <table class="queryTable">
                        <tbody>
                        <tr>
                            <th>项目名称</th>
                            <td width="10%">
                                <input id="auctionName" class="easyui-validatebox" type="text" name="auctionName"
                                       maxlength="50" style="width:120px;height: 15px;"/>
                            </td>
                            <th>项目编号</th>
                            <td>
                                <input id="code" class="easyui-validatebox" type="text" name="code" maxlength="20"
                                       style="width:120px;height: 15px;"/>
                            </td>
                            <th>项目类型</th>
                            <td width="10%">
                                <select class="easyui-combobox" name="catagoryId" style="width:120px;height: 25px;"
                                        maxlength="20" data-options="">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${projectTypeList}" var="type">
                                        <option value="${type.id}">${type.name}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <!--
								<th >资金来源</th>
							<td>
							 	<select id="moneySource" style="width:120px" class="easyui-combobox" name="moneySource">
							 		<option value="">--请选择--</option>
									<c:forEach items="${frame:dictChildren('moneySource')}" var="type">
										<option value="${type.value}">${type.name}</option>
									</c:forEach>
								</select>
							</td>
							 -->
                            <th>状态</th>
                            <td>
                                <select id="status" style="width:120px;height: 25px;" class="easyui-combobox"
                                        name="status">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${frame:dictChildren('proj_status')}" var="type">
                                        <option value="${type.value}">${type.name}</option>
                                    </c:forEach>
                                </select>
                            </td>
                            <th>保证金</th>
                            <td width="10%">
                                <select class="easyui-combobox" name="executePromissFilter"
                                        style="width:130px;height: 25px;" maxlength="20" data-options="">
                                    <option value="">--请选择--</option>
                                    <c:forEach items="${depostFilter}" var="type">
                                        <option value="${type.id}">${type.name}</option>
                                    </c:forEach>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>创建时间</th>
                            <td>
                                <input id="startTime" class="easyui-datebox" type="text" name="startTime"
                                       data-options="validType:['dateTimeLessCompare[\'stopTime\']']" maxlength="20"
                                       style="width:120px;height: 25px;"/>-<input id="stopTime" class="easyui-datebox"
                                                                                  type="text"
                                                                                  data-options="validType:['dateTimeMoreCompare[\'startTime\']']"
                                                                                  name="stopTime" maxlength="20"
                                                                                  style="width:120px;height: 25px;"/>
                            </td>
                            <th>开标时间</th>
                            <td>
                                <input id="startTime" class="easyui-datebox" type="text" name="bidTime"
                                       data-options="validType:['dateTimeLessCompare[\'stopTime\']']" maxlength="20"
                                       style="width:120px;height: 25px;"/>-<input id="stopTime" class="easyui-datebox"
                                                                                  type="text"
                                                                                  data-options="validType:['dateTimeMoreCompare[\'startTime\']']"
                                                                                  name="bidStopTime" maxlength="20"
                                                                                  style="width:120px;height: 25px;"/>
                            </td>

                            <td align="right" colspan="3">
                                <a href="javascript:void(0);" class="easyui-linkbutton" id="searchProjects"
                                   iconcls="icon-search" plain="true">查询</a>
                                <a href="javascript:void(0);" class="easyui-linkbutton" id="resetsearchProjects"
                                   iconcls="icon-reset" plain="true">清空</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
    <div data-options="region:'center',border:false" style="padding: 4px;">
        <div id="returnExecutefile"></div>
        <table id="listProjectsTable" class="easyui-datagrid"
               data-options="singleSelect:false,toolbar:'#goodstb',method:'post',rownumbers:true,fit:true,fitColumns:true,border:true,
					pagination:true,multiSort:true,remoteSort:true,striped:true,onLoadSuccess:function(data){$('#'+projectsParamObj.searchID).attr('disabled',false);},
					url:'${ctx}/auction/business/list?roleId=finance'" }>
            <thead>
            <tr>
                <th data-options="field:'auctionName',width:170,title:'项目名称',sortable:true" align="center"></th>
                <th data-options="field:'code',width:90,title:'项目编号',sortable:true" align="center"></th>
                <th data-options="field:'catagoryName',width:80,title:'项目类型',sortable:true" align="center"></th>
                <th data-options="field:'ownerName',width:120,title:'产权人',sortable:true" align="center"></th>
                <th data-options="field:'auditName',width:100,title:'中心审核人',sortable:true" align="center"></th>
                <th data-options="field:'createTime',width:100,title:'创建时间',sortable:true" align="center"></th>
                <th data-options="field:'entryStart',width:100,title:'报名时间',sortable:true" align="center"></th>
                <th data-options="field:'auctionStart',width:80,title:'竞拍开始时间 ',sortable:true" align="center"></th>
                <th data-options="field:'statusName',width:80,title:'状态',sortable:true" align="center"></th>
                <th data-options="field:'operation',width:160,title:'操作'" align="center"></th>
            </tr>
            </thead>
        </table>

        <!----------------------- wei start --------------------->
        <!--导出Excel -->
        <input type="hidden" id="excel_error" value="${requestScope.excel_error }"/>
        <script type="text/javascript">
            //导出
            function excelexport() {
                $("form").attr("action", "${ctx}/business/projectmanage/export")
                $("form").submit();

                var val = $("#excel_error").val();
                if (val != "") {//不为空提示错误消息
                    top.$.messager.alert("操作提示", val, "error");
                }
            }

        </script>
        <!----------------------- wei end --------------------->
    </div>
</div>
<div id="bindPicDialog"></div>
<div id="selPicDialog"></div>
<div id="noCompetReasonDialog"></div>
</body>
<script type="text/javascript">
    //初始化表格对应的js对象
    var projectsParamObj;
    $(function () {
        //初始化表格对象数据
        projectsParamObj = new initParams(
            {
                paramObjName: 'projectsParamObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
                tableId: 'listProjectsTable',
                addDataFormId: 'addProjectsDataForm',
                showDialogId: 'firstLevelDialog',
                searchID: 'searchProjects',
                resetSearchID: 'resetsearchProjects',
                searchFormID: 'searchProjectsForm',
                updateUrl: "${ctx}/business/projectmanage/input?projectId=",
                deleteUrl: '${ctx}/business/projectmanage/remove',
                addDialogWidth: 700,
                addDialogHeight: 520,
                ctx: '${ctx}',
                addDialogTitle: '采购项目信息'
            });
        //初始化查询
        init(projectsParamObj);
        //setTimeout(function(){
        //$.parser.parse(".optionsAreas");
        //},1000);
    });


    /**
     *项目详情
     */
    function getProjectDetail(id) {
        top.$('#threeLevelDialog').dialog({
            title: "项目详情",
            iconCls: 'icon-view',
            width: 1000,
            height: 580,
            closed: false,
            inline: true,
            cache: false,
            href: "${ctx}/auction/business/getProjectDetail?projectId=" + id + "&roleId=finance",
            modal: true,
            close: afterClosed,
            extractor: function (data) {
                if ($.trim(data) == "unLogin") {
                    var msn = '' || i18n[''];
                    msn = msn || i18n[data];
                    if (msn != undefined) {
                        top.$.messager.alert('提示', msn, 'info', function () {
                            top.location = '${ctx}/user-login-sys-new/loginPwd';
                        });
                        return '';
                    }
                }
                return data;
            },
            buttons: [{
                text: projectsParamObj.cancelButton,
                iconCls: 'icon-cancel',
                handler: function () {
                    top.$('#threeLevelDialog').dialog('close');
                }
            }]
        });
        top.$('#threeLevelDialog').dialog("center");
    }


    //保证金处理
    function returnDeposit(id) {
        top.$('#firstLevelDialog').dialog({
            title: "保证金",
            iconCls: 'icon-view',
            width: '1000',
            height: '500',
            closed: false,
            inline: true,
            cache: false,
            href: "${ctx}/auctionBid/business/leader/returnDepositPage?projectId=" + id,
            modal: true,
            close: afterClosed,
            extractor: function (data) {
                if ($.trim(data) == "unLogin") {
                    var msn = '' || i18n[''];
                    msn = msn || i18n[data];
                    if (msn != undefined) {
                        top.$.messager.alert('提示', msn, 'info', function () {
                            top.location = '${ctx}/user-login-sys-new/loginPwd';
                        });
                        return '';
                    }
                }
                return data;
            },
            onClose: function () {
                 //top.$('#firstLevelDialog').dialog('close');
                 $('#listProjectsTable').datagrid('reload');

            }

        });
        top.$('#firstLevelDialog').dialog("center");
    }

    //保证金明细
    function depositList(id) {
        top.$('#firstLevelDialog').dialog({
            title: "保证金",
            iconCls: 'icon-view',
            width: '1000',
            height: '500',
            closed: false,
            inline: true,
            cache: false,
            href: "${ctx}/auctionBid/business/leader/returnDepositDetailPage?projectId=" + id,
            modal: true,
            close: afterClosed,
            extractor: function (data) {
                if ($.trim(data) == "unLogin") {
                    var msn = '' || i18n[''];
                    msn = msn || i18n[data];
                    if (msn != undefined) {
                        top.$.messager.alert('提示', msn, 'info', function () {
                            top.location = '${ctx}/user-login-sys-new/loginPwd';
                        });
                        return '';
                    }
                }
                return data;
            },
            onClose: function () {
                  top.$('#firstLevelDialog').dialog('close');
                  $('#listProjectsTable').datagrid('reload');
            }
        });
        top.$('#firstLevelDialog').dialog("center");
    }

    //关闭
    function afterClosed() {

           $('#listProjectsTable').datagrid('reload');
//        top.$.find('.upload').hide();
        // 将弹出对话框还原成弹出前的状态，并清空里面的内容。
        //	top.$('#firstLevelDialog').dialog('destroy').empty();
//        top.$('#threeLevelDialog').dialog('destroy').empty();

    }


    //进入履约保证金明细页面
    function excuteDepositList(id) {
        top.$('#threeLevelDialog').dialog({
            title: "履约保证金",
            iconCls: 'icon-view',
            width: '800',
            height: '400',
            closed: false,
            inline: true,
            cache: false,
            href: "${ctx}/auctionBid/business/finance/returnExecutePage?projectId=" + id,
            modal: true,
            close: afterClosed,
            buttons: [
                {
                    text: '退款',
                    id: 'returnExecuteBt',
                    iconCls: 'icon-ok',
                    handler: function () {
                        var now = new Date(top.$("#now").val().replace(/\-/g, "\/"));
                        var backExecuteTime = new Date(top.$("#backExecuteTime").val().replace(/\-/g, "\/"));
                        if (backExecuteTime > now) {
                            top.$.messager.confirm('确认', '还没到履约保证金退还时间，是否退还履约保证金?', function (r) {
                                if (r) {
                                    $.ajax({
                                        type: 'post',
                                        url: '${ctx}/auctionBid/business/finance/returnExecuteDeposit',
                                        data: {
                                            projectId: id,
                                            projectName: null,
                                            bidderId: top.$("#bidderId").val(),
                                            hstSeqNum: top.$("#hstSeqNum").val(),
                                            budgetMenuData: top.$('#budgetMenuData').val(),
                                            companyName:top.$('#companyName').val()
                                        },
                                        success: function (data) {
                                            if (data == "bankTimeOut") {
                                                top.$.messager.alert('提示信息', '银行超时无响应！', 'error', function () {
                                                    //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                                    //$('#mydialog').datagrid('reload');
                                                });
                                            } else if (data == "saveSuccess") {
                                                top.$.messager.alert('提示信息', '退还申请成功,请等待银行处理结果！', 'info', function () {
                                                    top.$('#threeLevelDialog').dialog('close');//关闭加载数据
                                                    $('#listProjectsTable').datagrid('reload');
                                                    //$('#mydialog').datagrid('reload');
                                                });
                                            } else if (data == "saveUnsuccess") {
                                                top.$.messager.alert('提示信息', '退还申请失败，请确认后重新提交申请！', 'error', function () {
                                                    //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                                    //$('#mydialog').datagrid('reload');
                                                });
                                            } else if (data == "1") {
                                                top.$.messager.alert('提示信息', '履约保证金已经退还！', 'info', function () {
                                                    //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                                    //$('#mydialog').datagrid('reload');
                                                });
                                            } else if (data == "2") {
                                                top.$.messager.alert('提示信息', '履约保证金已经扣除！', 'error', function () {
                                                    //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                                    //$('#mydialog').datagrid('reload');
                                                });
                                            }
                                        }
                                    });
                                }
                            });

                        } else {
                            $.ajax({
                                type: 'post',
                                url: '${ctx}/auctionBid/business/finance/returnExecuteDeposit',
                                data: {
                                    projectId: id,
                                    projectName: null,
                                    bidderId: top.$("#bidderId").val(),
                                    hstSeqNum: top.$("#hstSeqNum").val(),
                                    budgetMenuData: top.$('#budgetMenuData').val(),
                                    companyName:top.$('#companyName').val()
                                },
                                success: function (data) {
                                    if (data == "bankTimeOut") {
                                        top.$.messager.alert('提示信息', '银行超时无响应！', 'error', function () {
                                            //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                            //$('#mydialog').datagrid('reload');
                                        });
                                    } else if (data == "saveSuccess") {
                                        top.$.messager.alert('提示信息', '退还申请成功,请等待银行处理结果！', 'info', function () {
                                             top.$('#threeLevelDialog').dialog('close');//关闭加载数据
                                             $('#listProjectsTable').datagrid('reload');
                                        });
                                    } else if (data == "saveUnsuccess") {
                                        top.$.messager.alert('提示信息', '退还申请失败，请确认后重新提交申请！', 'error', function () {
                                            //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                            //$('#mydialog').datagrid('reload');
                                        });
                                    } else if (data == "1") {
                                        top.$.messager.alert('提示信息', '履约保证金已经退还！', 'info', function () {
                                            //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                            //$('#mydialog').datagrid('reload');
                                        });
                                    } else if (data == "2") {
                                        top.$.messager.alert('提示信息', '履约保证金已经扣除！', 'error', function () {
                                            //top.$('#secondtLevelDialog').dialog('close');//关闭加载数据
                                            //$('#mydialog').datagrid('reload');
                                        });
                                    }
                                }
                            });

                        }
                    }
                },
                {
                    text: '完成履约保证金操作',
                    id: 'completeOpt',
                    iconCls: 'icon-ok',
                    handler: function () {
                        $.ajax({
                            type: 'post',
                            url: '${ctx}/auctionBid/business/leader/getReturnList',
                            data: {
                                projectId: id,
                                depositType: 1
                            },
                            success: function (data) {
                                if (data == "unPass") {
                                   top.$.messager.alert('提示信息', '存在已提交退款申请，银行未完成退还的状态！', 'error');
                                } else if (data == "allreturn") {
                                    top.$.messager.confirm('提示信息', '是否确认履约保证金退还操作完成？',
                                        function (r) {
                                            if (r) {
                                                $.ajax({
                                                    type: 'post',
                                                    url: '${ctx}/auctionBid/business/leader/finishDepositReturn',
                                                    data: {
                                                        projectId: id,
                                                        depositType: 1
                                                    },
                                                    success: function () {
                                                        top.$('#threeLevelDialog').dialog('close');
                                                        $('#listProjectsTable').datagrid('reload');
                                                    },

                                                });
                                            }
                                        });
                                } else if (data == "unallreturn") {
                                   top.$.messager.confirm('提示信息', '本项目尚存在未退还保证金，是否确认扣除这些投标人的保证金并完成保证金退还操作？',
                                        function (r) {
                                            if (r) {
                                                $.ajax({
                                                    type: 'post',
                                                    url: '${ctx}/auctionBid/business/leader/finishDepositReturn',
                                                    data: {
                                                        projectId: id,
                                                        depositType: 1
                                                    },
                                                    success: function () {
                                                        top.$('#threeLevelDialog').dialog('close');
                                                        $('#listProjectsTable').datagrid('reload');
                                                    },
                                                });
                                            }
                                        });
                                }
                            }
                        });


                    }
                },
                {
                    text: '取消',
                    iconCls: 'icon-cancel',
                    handler: function () {
                        top.$('#threeLevelDialog').dialog('close');
                    }
                }],
            onClose: function () {
                 $('#listProjectsTable').datagrid('reload');
                // top.$("#otherUpload1").uploadify('destroy');//销毁文件上传对象....
            }
        });
        top.$('#threeLevelDialog').dialog("center");

    }

    //履约保证金明细
    function showExcuteDeposit(id) {
        top.$('#firstLevelDialog').dialog({
            title: "履约保证金",
            iconCls: 'icon-view',
            width: '1000',
            height: '230',
            closed: false,
            inline: true,
            cache: false,
            href: "${ctx}/auctionBid/business/finance/excuteDepositList?projectId=" + id,
            modal: true,
            close: afterClosed,
            extractor: function (data) {
                if ($.trim(data) == "unLogin") {
                    var msn = '' || i18n[''];
                    msn = msn || i18n[data];
                    if (msn != undefined) {
                        top.$.messager.alert('提示', msn, 'info', function () {
                            top.location = '${ctx}/user-login-sys-new/loginPwd';
                        });
                        return '';
                    }
                }
                return data;
            },
            onClose: function () {
                $('#listProjectsTable').datagrid('reload');
            }
        });
        top.$('#firstLevelDialog').dialog("center");
    }
</script>